<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all">
    <script th:src="@{/plugins/layui/layui.js}"></script>
    <title>添加驾驶员</title>
</head>
<body>

<div style="padding-top: 20px;padding-right: 150px;padding-left: 100px;">
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">驾驶员名称</label>
            <div class="layui-input-block">
                <input type="text" name="tDrivername" required lay-verify="required|tDrivername" placeholder="驾驶员名称" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">身份证号</label>
            <div class="layui-input-block">
                <input type="text" name="tDriveridno" required lay-verify="required|tDriveridno" placeholder="身份证号" autocomplete="off"
                       class="layui-input" id="tDriveridno">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系方式</label>
            <div class="layui-input-block">
                <input type="text" name="tDriverphone" required lay-verify="required|tDriverphone" placeholder="联系方式" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block">
                <div class="layui-input-block">
                    <input type="radio" required lay-verify="required" name="tDriversex" value="男" title="男" checked>
                    <input type="radio" required lay-verify="required" name="tDriversex" value="女" title="女">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">物流公司</label>
            <div class="layui-input-block">
                <select id="tLogisticsid" name="tLogisticsid" lay-filter="tLogisticsid">
                  <option value="0">请选择物流公司</option>
                  <option th:each="list:${list}" th:value="${list.id}" th:text="${list.companyName}"></option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">驾驶证号</label>
            <div class="layui-input-block">
                <input type="text" name="tDriverlicense" required lay-verify="required|tDriverlicense" placeholder="驾驶证号" autocomplete="off"
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script>
    layui.use(['table', 'form'], function(){
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
        //新增
        form.on('submit(formDemo)', function(data){
            $.ajax({
                url:"/driver/d_add",
                data:data.field,
                dataType:'json',
                type:'post',
                async: false,
                success:function(mydata){
                    if (mydata) {
                        parent.layui.table.reload("demo");
                        parent.layer.msg('添加成功', {icon: 1});
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }else{
                        layer.msg('添加失败', {icon: 2});
                    }
                }
            });
        })
        form.verify({
            tDrivername:[
                /^[\u4e00-\u9fa5]{2,5}$/, '您的输入有误，请输入2-5位中文'
            ],
            tDriveridno:[
                /^[1-9]\d{5}(18|19|2([0-9]))\d{2}(0[0-9]|10|11|12)([0-2][1-9]|30|31)\d{3}[0-9Xx]$/,'身份证号码的格式错误'
            ],
            tDriverphone:[
                /^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/, '您的输入有误，请重新输入(中国11位手机号)'
            ]

        })
    })
</script>

</body>
</html>